$(document).ready(function () {
    var MyModal = (function() {
        function modal(fn) {
            this.fn = fn; //点击确定后的回调函数
            this._addClickListen();
        }
        modal.prototype = {
            show: function() {
                $('.case-model').fadeIn(100);
                $('.case-model').children('.case-model-content').fadeIn(100);
            },
            _addClickListen: function() {
                var that = this;
                $(".case-model").find('*').on("click", function(event) {
                    event.stopPropagation(); //阻止事件冒泡
                });
                $(".m-modal-close img").on("click", function() {
                    that.hide();
                });
            },
            hide: function() {
                var $modal = $('.case-model');
                $modal.children('.case-model-content').fadeOut(100);
                $modal.fadeOut(100);
            }
        };
        return {
            modal: modal
        }
    })();
    var imgSrcs=[
        "../img/caseDetails/qijiawang.png",
        "../img/caseDetails/pingan.png",
        "../img/caseDetails/wangyi.png",
        "../img/caseDetails/caishen.png",
        "../img/caseDetails/yiren.png",
        "../img/caseDetails/weipinhui.png",
        "../img/caseDetails/hujiang.png",
        "../img/caseDetails/gumi.png",
        "../img/caseDetails/huanqiu.png",
        "../img/caseDetails/INXX.png",
        "../img/caseDetails/qingtianzhu.png",
        "../img/caseDetails/qipaigame.png",
        "../img/caseDetails/jinshu.png",
        "../img/caseDetails/huaqi.png",
        "../img/caseDetails/zirantang.png",
        "../img/caseDetails/5100skincare.png",
    ];
    var m1 = new MyModal.modal();
    $(".casestudy-b a").click(function (e) {
        e.preventDefault();
        //在点击的标签上已经绑定索引,当做参数传给模态div
        var index=$(this).attr("href");
        var $showImg=$(this).parents(".row").siblings(".case-model").find(".case-study-show-img");
        $showImg.attr("src",imgSrcs[index]);
       m1.show();
    });
});